<HTML><HEAD><TITLE>library(regex)</TITLE></HEAD><BODY>
[ <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]<H1>library(regex)</H1>
Interface to POSIX regular expression handling
<H2>Predicates</H2>
<BLOCKQUOTE>
<DL>
<DT><A HREF="compile_pattern-3.html"><STRONG>compile_pattern(+Pattern, +Options, -CompiledPattern)</STRONG></A></DT>
<DD>Precompile a pattern for repeated use</DD>
<DT><A HREF="match-2.html"><STRONG>match(+Pattern, +String)</STRONG></A></DT>
<DD>A substring of String matches the regular expression Pattern</DD>
<DT><A HREF="match-3.html"><STRONG>match(+Pattern, +String, +Options)</STRONG></A></DT>
<DD>A substring of String matches the regular expression Pattern</DD>
<DT><A HREF="match-4.html"><STRONG>match(+Pattern, +String, +Options, -Match)</STRONG></A></DT>
<DD>Match is the first substring of String that matches the regular expression Pattern</DD>
<DT><A HREF="matchall-4.html"><STRONG>matchall(+Pattern, +String, +Options, -AllMatches)</STRONG></A></DT>
<DD>AllMatches is a list of substrings of String which match the regular expression Pattern</DD>
<DT><A HREF="matchsub-4.html"><STRONG>matchsub(+Pattern, +String, +Options, -SubMatches)</STRONG></A></DT>
<DD>A substring of String matches the regular expression Pattern and SubMatches are matching sub-expressions</DD>
<DT><A HREF="split-4.html"><STRONG>split(+Pattern, +String, +Options, -Parts)</STRONG></A></DT>
<DD>Parts is a list of substrings, partitioning String according to Pattern</DD>
</DL>
</BLOCKQUOTE>
<H2>Description</H2>

    This library implements an ECLiPSe API for POSIX 1003.2 regular
    expressions (on Unix systems it calls the regular expression
    functions from the standard library, on Windows it uses Henry
    Spencer's regex library version 3.8).

    <H3>Regular Expressions</H3>
    This is just a very brief summary of the essentials.  For details
    of regular expressions see any POSIX regex(7) man page.
    Two types of regular expressions are supported:
    <DL>
    <DT>Extended Regular Expressions (the default)</DT>
	<DD>These are described below and correspond essentially to those
	understood by the UNIX egrep command.</DD>
    <DT>Basic Regular Expressions</DT>
	<DD>These correspond essentially to those in the UNIX ed editor
	or the grep command, and are mostly obsolete.</DD>
    </DL>
    Note that our choice of default differs from the POSIX 1003.2 C API.

    <H4>Characters</H4>
    Every character stands for itself, except for the characters
    ^.[$()|*+?{\ which must be escaped with a \ to prevent
    them from having special meaning (and note that, since the ECLiPSe
    parser already interprets backslashes, you will have escape the
    backslash with another backslash in your ECLiPSe source string).
    <DL>
    <DT>.</DT>
	<DD>Matches any character</DD>
    <DT>[aeiou]</DT>
	<DD>Matches any of the characters between the brackets</DD>
    <DT>[^aeiou]</DT>
	<DD>Matches any character except those listed</DD>
    <DT>[a-z0-9]</DT>
	<DD>Matches any character in the given ranges</DD>
    </DL>

    <H4>Anchors</H4>
    <DL>
    <DT>^</DT>
	<DD>Matches at the beginning of the string (or line)</DD>
    <DT>$</DT>
	<DD>Matches at the end of the string (or line)</DD>
    </DL>

    <H4>Repetition</H4>
    <DL>
    <DT>?</DT>
	<DD>Matches the preceding element 0 or 1 times</DD>
    <DT>*</DT>
	<DD>Matches the preceding element 0 or more times</DD>
    <DT>+</DT>
	<DD>Matches the preceding element 1 or more times</DD>
    <DT>{3}</DT>
	<DD>Matches the preceding element 3 times</DD>
    <DT>{1,3}</DT>
	<DD>Matches the preceding element 1 to 3 times</DD>
    </DL>

    <H4>Grouping</H4>
    <DL>
    <DT>(subexpr)</DT>
	<DD>Matches the parenthesized expression. This grouping is used
	in connection with the repetition operators, or for indicating 
	subexpressions whose matches are to be captured and returned</DD>
    <DT>(one|two|three)</DT>
	<DD>Matches any of the alternative expressions</DD>
    </DL>

    <H3>Options</H3>
    Most of the predicates in this library accept a list of options.
    The accepted options are:
    <DL>
    <DT><TT>basic</TT></DT>
	<DD>Interpret the pattern as a Basic Regular Expression, rather
	than the default Extended Regular Expression.</DD>
    <DT><TT>extended</TT></DT>
	<DD>Interpret the pattern as an Extended Regular Expression
	(this flag is redundant since this is the default).</DD>
    <DT><TT>icase</TT></DT>
	<DD>Ignore case when matching.</DD>
    <DT><TT>newline</TT></DT>
	<DD>Treat newlines specially, i.e. don't treat them as normal
	characters and make ^ match after a newline and $ before a newline.
	By default, newlines are treated as ordinary characters.</DD>
    <DT><TT>notbol</TT></DT>
	<DD>Don't interpret the beginning of the string as the beginning
	of a line, i.e. don't let ^ match there.</DD>
    <DT><TT>noteol</TT></DT>
	<DD>Don't interpret the end of the string as the end of a line,
	i.e. don't let $ match there.</DD>
	<DD></DD>
    </DL>
    <H3>Shortcomings</H3>
    <OL>
    <LI>
    Due to limitations of the underlying implementation, the predicates
    in this library do not handle embedded NUL characters in strings correctly
    (they are interpreted as the end of the string).
    <LI>
    POSIX regular expressions don't seem to have a notion of  "noncapturing
    parentheses", i.e. parentheses that are only used for grouping, not for
    indicating that one wants to capture the matching substring.
    <LI>
    In an environment like ECLiPSe, one would like to be able to do things like
    <PRE>
	?- ideal_match("(/[^/]*)+", "/usr/local/eclipse", L).
	L = ["/usr", "/local", "/eclipse"]
	Yes
    </PRE>
    i.e. capture every instance of a matching subexpression.  There seems
    to be no way to do that with a POSIX regexp implementation.
    </OL>

<H2>About</H2><UL COMPACT>
<LI><STRONG>Author: </STRONG>J Chamois
<LI><STRONG>Copyright &copy; </STRONG>Public domain
<LI><STRONG>Date: </STRONG>$Date: 2009/02/19 05:45:20 $
</UL>
<HR>Generated from regex.eci on 2009-05-27 01:25
</BODY></HTML>
